package com.hibernate.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.javacommon.base.BaseEntity;

/**
 * 
 */

@Entity
@Table(name = "REPORT_AD_RESULT_HOUR")
public class ReportAdResultHour extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "广告效果时间段分布";
	public static final String ALIAS_ID = "ID";
	public static final String ALIAS_HOUR = "小时";
	public static final String ALIAS_BASE_ID = "基础数据记录ID";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * ID       db_column: ID 
     */ 	
	
	private Long id;
    /**
     * 小时       db_column: HOUR 
     */ 	
	@NotNull @Max(127)
	private Integer hour;
    /**
     * 基础数据记录ID       db_column: BASE_ID 
     */ 	
	@NotNull 
	private Long baseId;
	//columns END


	public ReportAdResultHour(){
	}

	public ReportAdResultHour(
		Long id
	){
		this.id = id;
	}

	

	public void setId(Long value) {
		this.id = value;
	}
	
	@Id
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "native") 
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getId() {
		return this.id;
	}
	
	@Column(name = "HOUR", unique = false, nullable = false, insertable = true, updatable = true, length = 2)
	public Integer getHour() {
		return this.hour;
	}
	
	public void setHour(Integer value) {
		this.hour = value;
	}
	
	@Column(name = "BASE_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getBaseId() {
		return this.baseId;
	}
	
	public void setBaseId(Long value) {
		this.baseId = value;
	}
	
//	
//	private ReportAdResultBase reportAdResultBase;
//	public void setReportAdResultBase(ReportAdResultBase reportAdResultBase){
//		this.reportAdResultBase = reportAdResultBase;
//	}
//	
//	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
//	@JoinColumns({
//		@JoinColumn(name = "BASE_ID",nullable = false, insertable = false, updatable = false) 
//	})
//	public ReportAdResultBase getReportAdResultBase() {
//		return reportAdResultBase;
//	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("Hour",getHour())
			.append("BaseId",getBaseId())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof ReportAdResultHour == false) return false;
		if(this == obj) return true;
		ReportAdResultHour other = (ReportAdResultHour)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	@Transient
	@Override
	public String getTarget() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public Long getTargetId() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public String getTargetName() {
		// TODO Auto-generated method stub
		return null;
	}
}

